package com.woyou.ui.adapter;

import java.util.List;

import com.citaq.ideliver.R;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * 地址搜索的适配器
 * 
 * @author nsz
 * 
 */
public class ShopSearchAdapter extends BaseAdapter {

	private List<String> mList;
	private Context mContext;

	public ShopSearchAdapter(List<String> mList, Context mContext) {
		super();
		this.mList = mList;
		this.mContext = mContext;
	}

	@Override
	public int getCount() {
		return mList.size();
	}

	@Override
	public Object getItem(int position) {
		return mList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = View.inflate(mContext, R.layout.item_shop_search_keys, null);
			holder.keyText = (TextView) convertView.findViewById(R.id.key_text);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		String myAddress = mList.get(position);
		holder.keyText.setText(myAddress);
		return convertView;
	}

	static class ViewHolder {
		TextView keyText;
	}

}
